import request from '../utils/request';
import { cloud } from '../utils/config';
  /**
   * 查询
   * @return  {[type]}  [description]
   * @author 李爽
   * @version [version]
   */
  export async function queryAll () {
    return request(`${cloud}/customer/query`,{
        method: 'get',
      }
    )
  }

 /**
  * 删除
  * @param   {[type]}  data [description]
  * @return  {[type]}       [description]
  * @author 李爽
  * @version [version]
  */
  export async function remove (data) {
    const id = data.payload.id;
    //console.log('remove:>>>>>',id);
    return request(`${cloud}/customer`, {
      method:'delete',
      body: JSON.stringify(id),
      data: JSON.stringify(id)
    })
  }

  /**
   * 批量删除
   * @param   {[type]}  data [description]
   * @return  {[type]}       [description]
   * @author 李爽
   * @version [version]
   */
   export async function deleteBatch (data) {
     //console.log('service deleteBatch:>>>>>',data);
     const id = data.id;

     return request(`${cloud}/customer`, {
       method:'delete',
       body: JSON.stringify(id),
       data: JSON.stringify(id)
     })
   }

  /**增加
   * @param   {[type]}  data [description]
   * @return  {[type]}       [description]
   * @author 李爽
   * @version [version]
   */
  export async function create (payload) {

    return request(`${cloud}/customer`,{
        method: 'post',
        body: JSON.stringify(payload),
        data: JSON.stringify(payload)
      }
    )
  }

/**
 * 修改
 * @param   {[type]}  payload [description]
 * @return  {[type]}          [description]
 * @author 李爽
 * @version [version]
 */
  export async function update (payload) {
    //console.log('>>>>>>',payload);
    return request(`${cloud}/customer`,{
        method: 'put',
        body: JSON.stringify(payload),
        data: JSON.stringify(payload)
      }
    )
  }

/**
 * 撤户
 * [method description]
 * @type {String}
 */
 export async function invalid (data) {

   return request(`${cloud}/customer/invalid`, {
     method:'put',
     body: JSON.stringify(data),
     data: JSON.stringify(data)
   })
 }
